import { Injectable } from '@angular/core';
import { RouterService } from '@kylin/router';
import { UserService } from '@kylin/core';
import { CacheService } from '@kylin/cache';
import { environment } from '../../environments/environment';
import { HttpService } from '@kylin/http';
import { Subject } from 'rxjs';

@Injectable()
export class MapService {

  private changeNzCollapsed = new Subject();
  nzCollapsedObservable = this.changeNzCollapsed.asObservable();

  constructor(private routerService: RouterService,
    private cacheService: CacheService
  ) {
  }

  $changeNzCollapsedObservable(value) {
    this.changeNzCollapsed.next(value);
  }
  /**
   * 登出
   */
  logout() {
    this.routerService.navigate('/login');
    this.cacheService.remove('siderData');
    this.cacheService.remove('token');
  }

  /**
   * 用于在进入home页面时候验证用户是否已经登陆,如果没有登陆,那么跳转到登陆页面
   */
  getSidebarMenuData() {
    if (false) {
      return this.cacheService.get('siderData').menuList;
    } else {
      return [
        {
          name: '首页',
          url: '/map',
          icon: 'windows'
        },
        {
          name: '数据导入',
          url: '/home/data-import',
          icon: 'rise'
        },
        {
          name: '地图统计',
          url: '/home/statistical-map',
          icon: 'global',
        },
        {
          name: '个人中心',
          url: '',
          icon: 'user',
          childMenu: [
            {
              name: '我的发布',
              icon: '',
              url: '/home/personal-center/release',
            },
            {
              name: '地图数据集系统',
              icon: '',
              url: '/home/personal-center/data-set'
            }
          ]
        }
      ];
    }
  }

}
